<?php


class Sherpa_Model_ColorApplication extends WSB_Model
{

	/**
	 * @var array
	 */
	protected $_data = array(
		// sherpa_colorApplications
		'id' => null,
		'primaryColorId' => null,
		'secondaryColorId' => null,
		'modified' => null,
		'created' => null,
		// sherpa_colors (color 1)
		/*'primaryColor' => null,
		'primaryRgbRed' => null,
		'primaryRgbGreen' => null,
		'primaryRgbBlue' => null,
		// sherpa_colors (color 2)
		'secondaryColor' => null,
		'secondaryRgbRed' => null,
		'secondaryRgbGreen' => null,
		'secondaryRgbBlue' => null,*/

		// sherpa_productToColorApplication
		'parentProductId' => null,
		'colors' => array()
	);

	/**
	 * @return Sherpa_Model_Colors
	 */
	public function getColors()
	{
		require_once(WSB_MODULES_PATH . 'sherpa/models/Colors.php');
		return new Sherpa_Model_Colors($this->_data['colors']);
	}

	/**
	 * @return array
	 */
	public function getColorNames()
	{
		require_once(WSB_MODULES_PATH . 'sherpa/models/Colors.php');
		$names = array();
		foreach(new Sherpa_Model_Colors($this->_data['colors']) AS $color) {
			$names[] = $color->getColorName();
		}
		return $names;
	}

	/**
	 * @return string
	 */
	public function getColorNamesAsString($delim = '/')
	{
		$names = $this->getColorNames();
		return implode($delim, $names);
	}

	/**
	 * @return string
	 */
	/*public function getPrimaryColorRgbHex()
	{
		return str_pad(dechex($this->getPrimaryRgbRed()), 2, '0', STR_PAD_LEFT).
			str_pad(dechex($this->getPrimaryRgbGreen()), 2, '0', STR_PAD_LEFT).
			str_pad(dechex($this->getPrimaryRgbBlue()), 2, '0', STR_PAD_LEFT);
	}*/

	/**
	 * @return boolean
	 */
	/*public function hasSecondaryColorRgb()
	{
		return intval($this->getSecondaryColorId()) != 0;
	}*/

	/**
	 * @return string
	 */
	/*public function getSecondaryColorRgbHex()
	{
		return str_pad(dechex($this->getSecondaryRgbRed()), 2, '0', STR_PAD_LEFT).
			str_pad(dechex($this->getSecondaryRgbGreen()), 2, '0', STR_PAD_LEFT).
			str_pad(dechex($this->getSecondaryRgbBlue()), 2, '0', STR_PAD_LEFT);
	}*/

	/**
	 * @return array
	 */
	/*public function getHexColors()
	{
		$colors = array();
		$colors[] = $this->getPrimaryColorRgbHex();
		if($this->hasSecondaryColorRgb()) {
			$colors[] = $this->getSecondaryColorRgbHex();
		}
		return $colors;
	}*/

}
